package org.xg.study.pd;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Map;

/**
 * @author CMG
 * @version 1.0
 * @description
 * @cLassName NetMall
 * @date 2021/9/18 9:40
 **/
public abstract class NetMall {
    protected Logger logger = LoggerFactory.getLogger(NetMall.class);

    String uId;//用户ID
    String uPwd;//用户密码

    public NetMall(String uId, String uPwd) {
        this.uId = uId;
        this.uPwd = uPwd;
    }

    /**
     * 生成商品推广海报
     * @param skuUrl 商品地址
     * @return 海报骨片base64位信息
     */
    public String generateGoodsPoster(String skuUrl){
        //1.验证登陆
        if(!login(uId,uPwd)){
            return null;
        }
        //2.爬虫商品
        Map<String,String> reptile = reptile(skuUrl);
        //3.组装海报
        return createBase64(reptile);
    }

    /**
     * 模拟登陆
     * @param uId
     * @param uPwd
     * @return
     */
    protected abstract Boolean login(String uId,String uPwd);

    /**
     * 爬虫提取商品信息
     * @param skuUrl
     * @return
     */
    protected abstract Map<String,String > reptile(String skuUrl);

    /**
     * 生成商品海报信息
     * @param goodsInfo
     * @return
     */
    protected abstract String createBase64(Map<String,String> goodsInfo);
}
